<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../../js/vue.min.js"></script>
    <script src="../../js/iview.min.js"></script>
    <link rel="stylesheet" href="../../css/iview.css">
</head>
<body>
<div id="app">
    {{message}}
    <my-component></my-component>
</div>
<script>
    var bus = new Vue();

    Vue.component('my-component', {
        template: "<button @click='handleEvent'>传递事件</button>",
        methods: {
            handleEvent: function () {
                bus.$emit("on-message", '来自孙子组件的通信');
            }
        }
    });
    var app = new Vue({
        el: "#app",
        data: {
            message: ""
        },
        mounted: function () {
            var _this = this;
            bus.$on('on-message', function (e) {
                _this.message = e;
            })
        }
    })
</script>
</body>
</html>